        var Lay = function(){
            var d = document, dd = d.documentElement, db = d.body, ua = navigator.userAgent.toLowerCase(), ie = !+'\v1', ie6 = /msie 6.0/.test(ua), id = 1, w = window, isStrict = d.compatMode == "CSS1Compat", $ = function(id, cont){
                return (cont || window).document.getElementById(id)
            }, m = Math.max, coverDiv, rycDiv , layDivs, ifm = d.getElementsByTagName('iframe'),
            oW ,oH , tmp,
            //得到view的宽高
            getWH = function(){
                return {
                    h: w.innerHeight || (isStrict ? dd.clientHeight : db.clientHeight),
                    w: w.innerWidth || (isStrict ? dd.clientWidth : db.clientWidth)
                }
            }, 
            //得到page的宽高
            getPageWH = function(){
                return {
                    h: isStrict ? m(dd.clientHeight, dd.scrollHeight) : m(db.clientHeight, db.scrollHeight),
                    w: isStrict ? m(dd.clientWidth, dd.scrollWidth) : m(db.clientWidth, db.scrollWidth)
                }
            }, 
            //得到scroll的top/left
            getS = function(){
                return {
                    t: isStrict ? dd.scrollTop : db.scrollTop,
                    l: isStrict ? dd.scrollLeft : db.scrollLeft
                };
            }, 
            extend = function(t, s){
                for (var p in s) {
                    t[p] = s[p]
                }
                return t;
            }, 
            //创建div,并追加到body
            creElm = function(o){
                var el = d.createElement('div');
                for (var p in o) {
                    p == 'style' ? el[p].cssText = o[p] : el[p] = o[p];
                }
                return db.insertBefore(el, db.firstChild);
            }, 
            //得到outerHTML
            creHtml = function(id, cont){
                var o = $(id, cont);
                return o && o.outerHTML;
            }, 
            //追加时间
            addEvt = function(t, o, f){
                for(var i=0,ci,t=t.split(' '),f=[].concat(f);ci=t[i];i++){
                    ie ? o.attachEvent('on' + ci, f[i]) : o.addEventListener(ci, f[i], false);
                }
            }, 
            //移除事件
            removeEvt = function(t, o, f){
                for(var i=0,ci,t=t.split(' '),f=[].concat(f);ci=t[i];i++){
                    ie ? o.detachEvent('on' + ci, f[i]) : o.removeEventListener(ci, f[i], false);
                }
            }, 
            //浮层调整大小
            resize = function(){
                if (coverDiv && coverDiv.style.display == 'block') {
                    coverDiv.style.display = 'none';
                    setTimeout(function(){
                        var pWH = getPageWH(), wh = getWH(), sTL = getS();
                        coverDiv.style.cssText += ";width:" + pWH.w + "px;height:" + pWH.h + "px;display:block;";
                        for (var p in layDivs) {
                            var o = layDivs[p], divs = o.getElementsByTagName('div');
                            for (var i = 0, ci; ci = divs[i++];) {
                                if (ci.className == 'watch_cont') {
                                    var w = o.opt.width, h = o.opt.height;
                                    w = w < 0 ? wh.w - (-2 * w) : w < 1 ? wh.w * w : w;
                                    h = h < 0 ? wh.h - (-2 * h) : h < 1 ? wh.h * h : h;
                                    ci.style.width = (wh.w - 50 < w ? wh.w - 50 : w) + 'px';
                                    ci.style.height = (wh.h - 100 < h ? wh.h - 70 : h) + 'px'
                                    o.style.margin = -o.offsetHeight / 2 + sTL.t + "px " + (-o.offsetWidth / 2 + sTL.l) + 'px'
                                }
                            }
                            
                        }
                    }, 0)
                }
            },
            lay = {
                //显示浮层
                show: function(o){
                    if(!rycDiv){
                        rycDiv = d.createElement('div');
                        layDivs = {};
                    };
                    var opt = extend({
                            disableClose: false,
                            disableTitleBar: false
                        }, o ||{}), wh = getWH(), pWH = getPageWH(), w = opt.width, h = opt.height, sTL = getS();
                    w = w < 0 ? wh.w - (-2 * w) : w < 1 ? wh.w * w : w;
                    h = h < 0 ? wh.h - (-2 * h) : h < 1 ? wh.h * h : h;
                    w = w > wh.w - 10 ? wh.w - 50 : w - 18;
                    h = h > wh.h - 10 ? wh.h - 50 : h - 18 - (opt.disableTitleBar ? 0 : 28);
                    var html = '<table cellpadding="0" cellspacing="0" ><tr><td class="top_left" >&nbsp;</td><td class="top_center" onmousedown="Lay.move(event,\'' + id + '\',this)" >' +
                    (opt.disableTitleBar ? '&nbsp;' : '<span  >' + (opt.title || '&nbsp;') + '</span>' + (opt.disableClose ? '' : '<img src="/images/lay/closebtn.gif" onclick=Lay.hide("' + (opt.name || "layDiv" + id) + '") class="close" onmouseover="this.src=\'/images/lay/closebtn_over.gif\'" onmouseout="this.src=\'/images/lay/closebtn.gif\'" />')) +
                    '</td><td class="top_right" >&nbsp;</td></tr>' +
                    '<tr class="window_main"><td class="layleft">&nbsp;</td><td class="center" style="overflow-y: hidden;width:' +
                    (w - 26) +'px;height:' + (h - 46) + 'px;" id="cont' + (opt.id || id) + '">' +
                    (opt.url ? '<iframe src=' + opt.url + ' frameBorder=0 width=100% height=100%  ></iframe>' : opt.id ? (ie ? creHtml(opt.id, opt.cont || window) : '') : opt.innerHTML) +
                    '</td><td class="layright" >&nbsp;</td></tr>' +
                    '<tr ><td class="bottom_left" >&nbsp;</td><td class="bottom_center" >&nbsp;</td><td class="bottom_right" onmouseover=this.style.cursor="nw-resize" onmouseout=this.style.cursor="default" onmousedown=Lay.resize(event,"'+id+'","'+(opt.id||id)+'",this) >&nbsp;</td></tr></table>';
                    tmp = layDivs[opt.name || "layDiv" + id] = creElm({
                        style: 'position:absolute;z-index:' + (999 + id * 2),
                        innerHTML: html,
                        id: "layDiv" + id,
                        hide: function(){
                            top.Lay.hide(this.id)
                        },
                        onOk: opt.onOk ? function(){
                            opt.onOk.apply(this,arguments)
                        } : function(){
                            top.Lay.hide(this.id)
                        },
                        onCancel: opt.onCancel ? function(){
                            opt.onCancel.call(this)
                        } : function(){
                            top.Lay.hide(this.id)
                        },
                        show: function(o){
                            top.Lay.show(o)
                        },
                        opt: opt
                    });
                    if(opt.url){
                        var ifm = tmp.getElementsByTagName('iframe')[0];
                        if (ifm) {
                            try {
                                ifm.onreadystatechange   =  ifm.onload = function(n){
                                    return function(){
                                        try{
                                        	this.contentWindow.focus()
                                            this.contentWindow.lay = tmp
                                        }catch(e){}
                                    }
                                }(opt.name||id)
                                ifm = null;
                            }catch (e) {}
                        }else {
                            tmp.focus();
                        }
                    }
                    if (opt.id && !ie) {
                        $('cont' + opt.id).appendChild($(opt.id, opt.cont || window).cloneNode(true));
                    };
                    oW = tmp.offsetWidth - 26;oH = tmp.offsetHeight - 46;
                    if (!coverDiv || coverDiv.style.display == 'none') {
                        if (!coverDiv) {
                            coverDiv = creElm({
                                style: "background:#c0c0c0;position:absolute;filter:alpha(opacity=50);opacity:0.5;top:0;left:0;z-index:999;",
                                innerHTML: ie6 ? "<iframe width=100% height=100% frameBorder=0 style=filter:alpha(opacity=0); )></iframe>" : ''
                            });
                        }
                        coverDiv.style.cssText += ";display:block;width:" + pWH.w + "px;height:" + pWH.h + "px;";     
                    };
                    coverDiv.style.zIndex = 998 + id * 2;
                    tmp.style.cssText += ";margin:" + (-tmp.offsetHeight / 2 + sTL.t) + 'px ' + (-tmp.offsetWidth / 2 + sTL.l) + 'px;top:50%;left:50%;display:block';
                    id++;
                },
                //销毁浮层
                hide: function(){
                    if (arguments.length > 0) {
                        for (var i = 0, ci; ci = arguments[i++];) {
                            rycDiv.appendChild(layDivs[ci]);
                            delete layDivs[ci];
                        }
                    }
                    else {
                        for (var p in layDivs) {
                            rycDiv.appendChild(layDivs[p])
                            delete layDivs[p];
                        }
                    };
                    rycDiv.innerHTML = null;
                    var c = 0, max = 0;
                    for (var p in layDivs) {
                        c++;
                        var t = p.match(/\d+/) * 1;
                        max = max < t ? t : max
                    }
                    if (c == 0) {
                        rycDiv.appendChild(coverDiv)
                        rycDiv.innerHTML = null;
                        coverDiv = rycDiv = layDivs = tmp = null;
                    }
                    else {
                        coverDiv.style.zIndex = 998 + max * 2
                    }
                },
                //浮层移动
                move: function(e, id, o){
                    e = e || event;
                    var sDiv = $('layDiv' + id), lt = getS(), wh=getWH(),x = e.clientX - sDiv.offsetLeft + lt.l, y = e.clientY - sDiv.offsetTop + lt.t,
                        upFn = function(){
                            removeEvt('mousemove mouseup', d, [moveFn,upFn]);
                            ie && o.releaseCapture();
                            o.style.cursor = 'default';
                        }, moveFn = function(evt){
                            evt = evt || event;
                            o.style.cursor = 'move';
                            ie && o.setCapture();
                            window.getSelection ? window.getSelection().removeAllRanges() : d.selection.empty();
                            extend(sDiv.style,{
                                top:(evt.clientY - y <= 0 ? 0 : evt.clientY - y + sDiv.offsetHeight >=wh.h ? wh.h - sDiv.offsetHeight : evt.clientY - y) + lt.t +'px',
                                left:(evt.clientX - x <= 0 ? 0 : evt.clientX - x + sDiv.offsetWidth >= wh.w ? wh.w - sDiv.offsetWidth : evt.clientX - x) + lt.l +'px'
                            });
                        };
                        extend(sDiv.style,{top:sDiv.offsetTop + 'px',left:sDiv.offsetLeft + 'px',margin:''})
                        addEvt('mousemove mouseup', d,[moveFn,upFn]);
                },
                //浮层大小
                resize:function(e,id,cid,o){
                    e = e || event;
                    var sDiv = $('layDiv' + id),cont = $('cont'+cid), lt = getS(), wh=getWH(),
                        upFn = function(){
                            removeEvt('mousemove mouseup', d, [moveFn,upFn]);
                            ie && o.releaseCapture();
                        }, moveFn = function(evt){
                            evt = evt || event;
                            ie && o.setCapture();
                            window.getSelection ? window.getSelection().removeAllRanges() : d.selection.empty();
                            var tmpW = evt.clientX - sDiv.offsetLeft - cont.offsetLeft +lt.l,
                                tmpH = evt.clientY - sDiv.offsetTop - cont.offsetTop + lt.t;
                            extend(cont.style,{width:(tmpW<oW?oW:tmpW) + 'px',height:(tmpH<oH?oH:tmpH+sDiv.offsetTop-lt.t>wh.h-60?wh.h-sDiv.offsetTop+lt.t-60:tmpH) +'px'})
                        };
                        addEvt('mousemove mouseup', d,[moveFn,upFn]);
                        extend(sDiv.style,{top:sDiv.offsetTop + 'px',left:sDiv.offsetLeft + 'px',margin:''})
                }
            };
            //如果页面有iframe,为其添加lay对象
            ifm[0]&&(ifm[0][ie?'onreadystatechange':'onload'] = function(){
                this.contentWindow&&(this.contentWindow.Lay = lay)
            })                  
            addEvt('resize',window,resize);
            return lay;     
    }()